/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controle.controladores;

/**
 *
 * @author Taeko
 */
public class PI extends ControladorAbstrato{

    private proporcional p;
    private integrativo i;
    private double integral = 0.0, saida = 0.0;
    
    public PI(double Kp, double Ki)
    {
        super(Kp, Ki, 0);
        
        p = new proporcional(Kp);
        i = new integrativo(Ki);
    }
    
    @Override
    public double valorControle(double entrada, double h) {
        p.setContantes(Kp, Ki, Kd);
        i.setContantes(Kp, Ki, Kd);
        
        return  p.valorControle(entrada, h) + i.valorControle(entrada, h);
    }
    
    public double valorControle2(double saida, double erro, double dt){
        if((saida >= 3 && erro>0) || (saida <= -3 && erro <0)){
            
        }else{
            integral = integral + (erro * dt);
        }
        
        this.saida = (p.Kp * erro) + (i.Ki * integral);
        return this.saida;
    }
    
}
